//
//  BookReadTypeView.m
//  Learn
//
//  Created by 迟建国 on 2024/4/4.
//  Copyright © 2024 迟建国. All rights reserved.
//

#import "BookReadTypeView.h"

@implementation BookReadTypeView

+ (BookReadTypeView *)chooseTypeWithVc:(UIViewController *)vc Complection:(void(^)(NSString *str))block {
    BookReadTypeView *  inputView;
    inputView = [[BookReadTypeView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
    [inputView initUI];
    inputView.chooseBlock = block;
    
    NSLog(@"%@", NSObject.getKeyWindowRootViewController);
    [NSObject.getKeyWindowRootViewController gq_presentLikeAlertView:inputView];
    NSObject.getKeyWindowRootViewController.gq_enableBlankDismiss = YES;
    
    return inputView;
}

- (void)initUI {
    UIView *bgView = [[UIView alloc] initWithFrame:self.bounds];
    bgView.backgroundColor = [UIColor blackColor];
    bgView.alpha = 0.75;
    [self addSubview:bgView];
    
    UIButton *followBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    followBtn.layer.cornerRadius = 50;
    followBtn.layer.masksToBounds = YES;
    followBtn.backgroundColor = rgba(255, 153, 23, 1);
    [followBtn setTitle:@"跟读" forState:UIControlStateNormal];
    [followBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    followBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:20];
    [followBtn addTarget:self action:@selector(follow) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:followBtn];
    [followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY).offset(-80);
        make.width.height.offset(100);
    }];
    
    UIButton *readBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    readBtn.layer.cornerRadius = 50;
    readBtn.layer.masksToBounds = YES;
    readBtn.backgroundColor = rgba(255, 153, 23, 1);
    [readBtn setTitle:@"朗读" forState:UIControlStateNormal];
    [readBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    readBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Semibold" size:20];
    [readBtn addTarget:self action:@selector(read) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:readBtn];
    [readBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.centerY.equalTo(self.mas_centerY).offset(80);
        make.width.height.offset(100);
    }];
}
- (void)follow {
    self.chooseBlock(@"跟读");
    [NSObject.getKeyWindowRootViewController gq_removeBgView];
}
- (void)read {
    self.chooseBlock(@"朗读");
    [NSObject.getKeyWindowRootViewController gq_removeBgView];
}
@end
